#!/bin/bash
# Zaitan Module - AssaultCube Install
# Zaitan Team <http://code.google.com/p/zaitan/>

RMOD_ENGINE='1.0'
RMOD_CATEGORY='Software'
RMOD_SUBCATEGORY='Games'
RMOD_NAME='AssaultCube'
RMOD_AUTHOR='Zaitan Team'
RMOD_VERSION='0.93'
RMOD_DESCRIPTION='Installs AssaultCube'
RMOD_UPDATE_URL='http://code.google.com/p/zaitan/'

# install AssaultCube

echo Running $RMOD_NAME...
#/usr/lib/zaitan/modulo/mod-checkInstall


apt-get update

debs='libsdl-net1.2 libsdl-image1.2 libsdl-mixer1.2'
for i in $debs; do
VERIFIQ=$(dpkg -s "$i" 2> /dev/null | grep "Status:" | awk '{ print $3 }')


	if [ "$VERIFIQ" != "ok" ]; then

	apt-get -y install $i
	sleep 1
	
	else
	echo "$i já está instalado"
	sleep 2
fi
done

cd /usr/share/zaitan


mkdir CUBE

wget -c http://switch.dl.sourceforge.net/sourceforge/actiongame/AssaultCube_v0.93.tar.bz2
tar -vxjpf AssaultCube_v0.93.tar.bz2

mv AssaultCube CUBE/
mv CUBE /usr/share/games
 
echo 'cd /usr/share/games/CUBE/AssaultCube && sh assaultcube.sh' > ac && chmod +x ac && mv ac /usr/local/bin 

echo '[Desktop Entry]
Name=AssaultCube
Comment=Tiro
Exec=ac
Icon=/usr/share/games/CUBE/AssaultCube/ac.png
Terminal=false
Type=Application
Categories=Application;Game;' > AssaultCube.desktop

mv AssaultCube.desktop /usr/share/applications/

cp /usr/share/zaitan/glade/ac.png /usr/share/games/CUBE/AssaultCube/


echo $RMOD_NAME Finibashed...

##Logs
echo $RMOD_NAME-$RMOD_VERSION | tee -a /usr/share/zaitan/logs
/usr/lib/zaitan/modulo/mod-logs
##

exit 0
